package com.ydch.spring.test;

import java.util.concurrent.BlockingQueue;

//Producer Class in java
class Producer implements Runnable {

  private final BlockingQueue<String> sharedQueue;

  public Producer(BlockingQueue<String> sharedQueue) {
      this.sharedQueue = sharedQueue;
  }

  @Override
  public void run() {
      for(int i=0; i<1000; i++){
          try {
        	  System.out.println("开始生产数据-----------");
              sharedQueue.put("Produced message aaaaaaaaaaa!"+i);
              Thread.sleep(5000);
          } catch (InterruptedException ex) {
          }
      }
  }

}